<template>
	<view class="login-view">
		<image src="../static/yonghu.png" mode="widthFix"></image>
		<button type="primary" @click="login">登录</button>
	</view>
</template>

<script setup>
	import { requestapi } from '@/api/request.js'
	import { porch } from '/api/wechat.js'
	
	function wxlogin(){
		uni.login({
		  provider: 'weixin', //使用微信登录
		  success: async(loginRes) =>{
		    const member = await porch(loginRes.code);
			uni.setStorageSync('memberInfo',member.data)
			console.info(member.data)
			//返回上一个界面
			uni.navigateBack({delta:1})
		  },
		  fail:(err)=>{
			  console.log(err)
		  }});
	}
	

	function login() {
		wxlogin()
	}
	
	
</script>

<style lang="less">
	page{
			background-image: url('https://qita-1252107261.cos.ap-chengdu.myqcloud.com/motuoche.jpg');
			background-position: center center;
			background-repeat: no-repeat;
			background-size: cover;
			/* background: linear-gradient(to bottom, #b3cffa, #f6f8fe); */
		}
		.login-view{
			display: flex;
			flex-direction: column;
			align-items: center;
			padding: 0 80rpx;
			margin-top: 400rpx;
			font-size: 35rpx;
		}
		.login-view image{
			width: 150rpx;
		}
		.login-view button{
			width: 100%;
			margin-top: 100rpx;
		}
</style>